package com.qgs.secsgem.secs.eq;

import com.qgs.secsgem.mq.configuration.ConfigOfPID24a;
import com.qgs.secsgem.mq.producer.component.RabbitSender;
import com.qgs.secsgem.secs.eq.runnable.PID24aRunnable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2023/4/12 10:52
 */
@Component
@Order(value = 1)
public class EQJoinThread implements ApplicationRunner {
    private static final Logger logger = LoggerFactory.getLogger(EQJoinThread.class);

    @Autowired
    RabbitSender rabbitSender;
    public EQJoinThread(){
        this.pid10 = Executors.newScheduledThreadPool(1);
        this.pid18 = Executors.newScheduledThreadPool(1);
        this.pid24a = Executors.newScheduledThreadPool(1);
    }

    private ScheduledExecutorService pid10;
    private ScheduledExecutorService pid18;
    private ScheduledExecutorService pid24a;




    @Override
    public void run(ApplicationArguments args) throws Exception {
        //pid10.scheduleAtFixedRate(new PID10Runnable("PID10","127.0.0.1",7000,rabbitSender, ConfigOfPID10_1.EXCHANGE_NAME_PID10_1,ConfigOfPID10_1.EAP_REQUEST_QUEUE_ROUTINGKEY_PID10_1,ConfigOfPID10_1.MES_REQUEST_QUEUE_ROUTINGKEY_PID10_1,PID10Runnable.VID_Type,PID10Runnable.ECID_Type),1,1, TimeUnit.SECONDS);
        //pid18.scheduleAtFixedRate(new PID18Runnable("PID18","192.168.1.56",5000,rabbitSender, ConfigOfPID18.EXCHANGE_NAME_PID18,ConfigOfPID18.EAP_REQUEST_QUEUE_ROUTINGKEY_PID18,ConfigOfPID18.MES_REQUEST_QUEUE_ROUTINGKEY_PID18,PID18Runnable.SVID_Type, PID18Runnable.ECID_Type),1,1, TimeUnit.SECONDS);
        pid24a.scheduleAtFixedRate(
                new PID24aRunnable(
                        "PID24a",
                        "127.0.0.1",
                        5000,
                        rabbitSender,
                        ConfigOfPID24a.EXCHANGE_NAME_PID24a,
                        ConfigOfPID24a.EAP_REQUEST_QUEUE_ROUTINGKEY_PID24a,
                        ConfigOfPID24a.MES_REQUEST_QUEUE_ROUTINGKEY_PID24a,
                        "U4",
                        "U4",
                        "U4",
                        "U4",
                        "U4"
                ),

                1,1, TimeUnit.SECONDS);

    }
}
